﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;

/// <summary>
///workerDAL 的摘要说明
/// </summary>
public class EmployeeDAL
{
    protected String connString = ConfigurationManager.ConnectionStrings["ConStr"].ToString();

    public EmployeeDAL()
     { 

     }



    public EmployeeInfo GetEmployeeById(int Id)
    {
        SqlConnection conn = new SqlConnection(connString);
        try
        {
            conn.Open();
            String cmdText = "SELECT * FROM tb_EmployeeInfo WHERE Id='" +
                Id+ "'";
            SqlCommand cmd = new SqlCommand(cmdText, conn);
            SqlDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                EmployeeInfo b = new EmployeeInfo();
                b.Id = Int32.Parse(dr["Id"].ToString());
                //b.Id = dr["Id"].ToString();
                b.Name = dr["Name"].ToString();                   //姓名
                b.Department = dr["Department"].ToString();       //部门
                b.Position = dr["Position"].ToString();            //职务
                b.Sex = dr["Sex"].ToString();                     //性别
                b.BirthdayYang = dr["BirthdayYang"].ToString();     //生日
                b.BloodType = dr["BloodType"].ToString();           //血型                
                b.Nation = dr["Nation"].ToString();                   //民族
                b.Origin = dr["Origin"].ToString();                   //籍贯
                b.Political = dr["Political"].ToString();                //政治面貌
                b.GraduationTime = dr["GraduationTime"].ToString();       //毕业时间
                b.GraduationSchool = dr["GraduationSchool"].ToString();    //毕业学校
                b.Edu1 = dr["Edu1"].ToString();                            //第一学历
                b.Edu1Professional = dr["Edu1Professional"].ToString();      //专业
                b.Edu1Degree = dr["Edu1Degree"].ToString();                     //第一学位
                b.Edu2 = dr["Edu2"].ToString();                              //第二学位
                b.Edu2Professional = dr["Edu2Professional"].ToString();            //专业
                b.Edu2Degree = dr["Edu2Degree"].ToString();                         //第二学位
                b.ForLanLev = dr["ForLanLev"].ToString();                           //外语水平
                b.ComLev = dr["ComLev"].ToString();                                  //计算机水平
                b.IDCard = dr["IDCard"].ToString();                                  //身份证号
                b.PerReside = dr["PerReside"].ToString();                            //户口所在地
                b.Marrige = dr["Marrige"].ToString();                               //婚姻状况
                b.WorkExper = dr["WorkExper"].ToString();                          //工作年限
                b.Health = dr["Health"].ToString();                                //健康状况
                b.Address = dr["Address"].ToString();                                //详细住址
                b.OtherAddress = dr["OtherAddress"].ToString();                       //其他住址
                b.Phone = dr["Phone"].ToString();                                        //座机
                b.TelePhone = dr["TelePhone"].ToString();                               //手机
                b.EMail = dr["EMail"].ToString();                                  //email
                b.QQ = dr["QQ"].ToString();                                        //QQ
                b.EmerPer = dr["EmerPer"].ToString();                            //紧急时刻联系人
                b.EmerPhone = dr["EmerPhone"].ToString();                            //紧急时刻联系电话
                b.WorkTime = dr["WorkTime"].ToString();                               //参加工作时间
                b.PostTime = dr["PostTime"].ToString();                              //正是上岗时间
                b.Rec = dr["Rec"].ToString();                                          //是否有员工推荐
                b.RecName = dr["RecName"].ToString();                                   //推荐人
                b.Fam = dr["Fam"].ToString();                                              //公司内是否有家属
                b.FamName = dr["FamName"].ToString();                              //家属姓名
                b.danwei = dr["danwei"].ToString();                                  //单位                            没有
                b.FamPosition = dr["FamPosition"].ToString();                        //职务
                b.Experience = dr["Experience"].ToString();                             //工作经历
                b.Honors = dr["Honors"].ToString();                                    //所获荣誉
                b.SocialRelation = dr["SocialRelation"].ToString();                     //社会关系
                b.InAndHo = dr["InAndHo"].ToString();                                   //兴趣特长     
                b.SelfAsse = dr["SelfAsse"].ToString();                             //自我评价
                b.Wage = dr["Wage"].ToString();                                      //工资
                b.Pic = dr["Pic"].ToString();
                conn.Close();
                return b;
            }
            else
            {
                throw new Exception("未找该员工信息");
            }
        }
        catch (Exception ex)
        {
            conn.Close();
            throw ex;
        }
    }
}